/*
 * XOWLGMIEnvironmentView.java
 */

package xowl.gmi.view;

import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import xowl.gmi.environment.Locale;
import xowl.gmi.environment.Properties;

/**
 * The application's main frame.
 */
public class MainView extends FrameView {
    public static interface Actions extends WinProjects.Actions {
        void onFileCloseProject(ProjectNode pv);
        void onFileExport(ProjectNode pv, DiagramView dv);
        void onFileSave(ProjectNode pv);
        void onFileSaveAs(ProjectNode pv);
        void onFileSaveAll();
        void onEditUndo();
        void onEditRedo();
        void onEditCut(DiagramView dv);
        void onEditCopy(DiagramView dv);
        void onEditPaste(DiagramView dv);
        void onEditRemove(DiagramView dv);
        void onEditDelete(DiagramView dv);
        void onRunExecute(ProjectNode pv, String execID);
        void onHelpBug();
    }
    
    private int counter;
    private Actions actions;
    private Properties properties;
    private Locale locale;
    private ViewStyle style;
    private WinProjects winProjects;
    private WinToolboxes winToolboxes;
    private WinOutput winOutput;
    private org.noos.xing.mydoggy.plaf.MyDoggyToolWindowManager station;
    private org.noos.xing.mydoggy.ToolWindow twProjects;
    private org.noos.xing.mydoggy.ToolWindow twToolboxes;
    private org.noos.xing.mydoggy.ToolWindow twOutput;
    private boolean inhibited;
    
    public WinProjects getWinProjects() { return winProjects; }
    public WinOutput getWinOutput() { return winOutput; }
    
    public MainView(SingleFrameApplication app, Properties properties, Locale locale, Actions actions) {
        super(app);
        this.actions = actions;
        this.properties = properties;
        this.locale = locale;
        this.style = new ViewStyle();
        initComponents();
        this.getFrame().setTitle(locale.title);
        winProjects = new WinProjects(actions, locale, style);
        winToolboxes = new WinToolboxes();
        winOutput = new WinOutput(style);
        
        station = new org.noos.xing.mydoggy.plaf.MyDoggyToolWindowManager();
        station.getContentManager().setContentManagerUI(new org.noos.xing.mydoggy.plaf.ui.content.MyDoggyTabbedContentManagerUI());
        station.getContentManager().addContentManagerListener(new org.noos.xing.mydoggy.ContentManagerListener() {
            @Override public void contentAdded(org.noos.xing.mydoggy.event.ContentManagerEvent cme) {
                DiagramView dv = (DiagramView)cme.getContent().getComponent();
                winToolboxes.setToolboxes(dv.getToolboxes());
            }
            @Override public void contentRemoved(org.noos.xing.mydoggy.event.ContentManagerEvent cme) {
                if (inhibited) return;
                DiagramView dv = (DiagramView)cme.getContent().getComponent();
                dv.onDiagramRemoved();
                if (station.getContentManager().getContentCount() == 0)
                    winToolboxes.setToolboxes(null);
            }
            @Override public void contentSelected(org.noos.xing.mydoggy.event.ContentManagerEvent cme) {
                DiagramView dv = (DiagramView)cme.getContent().getComponent();
                winToolboxes.setToolboxes(dv.getToolboxes());
            }
        });
        contentPanel.setLayout(new java.awt.BorderLayout());
        contentPanel.add(station, java.awt.BorderLayout.CENTER);
        
        twProjects = station.registerToolWindow("projects", locale.winProjects, IconProvider.getEmbedded("projects.png"), winProjects, org.noos.xing.mydoggy.ToolWindowAnchor.LEFT);
        twProjects.setAutoHide(false);
        twProjects.setVisible(true);
        org.noos.xing.mydoggy.DockedTypeDescriptor dkDesc = (org.noos.xing.mydoggy.DockedTypeDescriptor) twProjects.getTypeDescriptor(org.noos.xing.mydoggy.ToolWindowType.DOCKED);
        dkDesc.setIdVisibleOnTitleBar(false);
        dkDesc.setTitleBarButtonsVisible(false);
        
        twToolboxes = station.registerToolWindow("toolbox", locale.winToolbox, IconProvider.getEmbedded("toolbox.png"), winToolboxes, org.noos.xing.mydoggy.ToolWindowAnchor.RIGHT);
        twToolboxes.setVisible(true);
        dkDesc = (org.noos.xing.mydoggy.DockedTypeDescriptor) twToolboxes.getTypeDescriptor(org.noos.xing.mydoggy.ToolWindowType.DOCKED);
        dkDesc.setIdVisibleOnTitleBar(false);
        dkDesc.setTitleBarButtonsVisible(false);
        
        twOutput = station.registerToolWindow("output", locale.winOutput, IconProvider.getEmbedded("output.png"), winOutput, org.noos.xing.mydoggy.ToolWindowAnchor.BOTTOM);
        twOutput.setVisible(true);
        dkDesc = (org.noos.xing.mydoggy.DockedTypeDescriptor) twOutput.getTypeDescriptor(org.noos.xing.mydoggy.ToolWindowType.DOCKED);
        dkDesc.setIdVisibleOnTitleBar(false);
        dkDesc.setTitleBarButtonsVisible(false);
        dkDesc.setAutoHide(true);
    }
    
    public void addExecutionChoice(final String id, String name) {
        int count = runMenu.getItemCount();
        javax.swing.JMenuItem item = new javax.swing.JMenuItem(name, IconProvider.getEmbedded("play.png"));
        item.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_0 + count, java.awt.event.InputEvent.CTRL_MASK));
        item.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override public void mouseReleased(java.awt.event.MouseEvent evt) {
                ProjectNode selection = winProjects.getSelectedProject();
                    if (selection != null)
                actions.onRunExecute(selection, id);
            }
        });
        runMenu.add(item);
    }
    
    public void setUndoStatus(String tooltip) {
        if (tooltip == null) {
            editUndo.setEnabled(false);
            editToolUndo.setEnabled(false);
            editToolUndo.setToolTipText(locale.editUndo_text);
        } else {
            editUndo.setEnabled(true);
            editToolUndo.setEnabled(true);
            editToolUndo.setToolTipText(locale.editUndo_text + " " + tooltip);
        }
    }
    public void setRedoStatus(String tooltip) {
        if (tooltip == null) {
            editRedo.setEnabled(false);
            editToolRedo.setEnabled(false);
            editToolRedo.setToolTipText(locale.editRedo_text);
        } else {
            editRedo.setEnabled(true);
            editToolRedo.setEnabled(true);
            editToolRedo.setToolTipText(locale.editRedo_text + " " + tooltip);
        }
    }
    
    public void addOpenTab(String title, DiagramView dv) {
        String id = "diagram" + Integer.toString(counter);
        counter++;
        org.noos.xing.mydoggy.Content content = station.getContentManager().addContent(id, title, IconProvider.getEmbedded("diagram.png"), dv, title);
        content.setSelected(true);
        content.getContentUI().setDetachable(false);
        content.getContentUI().setMinimizable(false);
        ((org.noos.xing.mydoggy.plaf.ui.content.MyDoggyTabbedContentManagerUI)station.getContentManager().getContentManagerUI()).setShowAlwaysTab(true);
    }
    
    public void removeOpenTab(DiagramView dv) {
        inhibited = true;
        org.noos.xing.mydoggy.Content content = station.getContentManager().getContentByComponent(dv);
        station.getContentManager().removeContent(content);
        inhibited = false;
        if (station.getContentManager().getContentCount() == 0)
            winToolboxes.setToolboxes(null);
    }

    public void makeOutputVisible() {
        station.getToolWindow(3).setVisible(true);
    }
    
    private DiagramView getCurrentTab() {
        org.noos.xing.mydoggy.Content content = station.getContentManager().getSelectedContent();
        if (content == null) return null;
        return (DiagramView)content.getComponent();
    }
    
    @Action public void fileNewProject() { actions.onFileNewProject(); }
    @Action public void fileNewDiagram() { actions.onFileNewDiagram(); }
    @Action public void fileOpenProject() { actions.onFileOpenProject(); }
    @Action public void fileCloseProject() {
        ProjectNode selection = winProjects.getSelectedProject();
        if (selection != null) actions.onFileCloseProject(selection);
    }
    @Action public void fileExport() { actions.onFileExport(winProjects.getSelectedProject(), getCurrentTab()); }
    @Action public void fileSave() {
        ProjectNode selection = winProjects.getSelectedProject();
        if (selection != null) actions.onFileSave(selection);
    }
    @Action public void fileSaveAs() {
        ProjectNode selection = winProjects.getSelectedProject();
        if (selection != null) actions.onFileSaveAs(selection);
    }
    @Action public void fileSaveAll() { actions.onFileSaveAll(); }
    
    @Action public void editUndo() { actions.onEditUndo(); }
    @Action public void editRedo() { actions.onEditRedo(); }
    @Action public void editCut() {
        DiagramView tab = getCurrentTab();
        if (tab != null) actions.onEditCut(tab);
    }
    @Action public void editCopy() {
        DiagramView tab = getCurrentTab();
        if (tab != null) actions.onEditCopy(tab);
    }
    @Action public void editPaste() {
        DiagramView tab = getCurrentTab();
        if (tab != null) actions.onEditPaste(tab);
    }
    @Action public void editRemove() {
        DiagramView tab = getCurrentTab();
        if (tab != null) actions.onEditRemove(tab);
    }
    @Action public void editDelete() {
        DiagramView tab = getCurrentTab();
        if (tab != null) actions.onEditDelete(tab);
    }
    
    @Action public void viewRequestProjects() { }
    @Action public void viewRequestToolboxes() { }
    @Action public void viewRequestOutput() { }
    @Action public void zoomPlus() {
        DiagramView tab = getCurrentTab();
        if (tab != null) tab.zoomPlus();
    }
    @Action public void zoomMinus() {
        DiagramView tab = getCurrentTab();
        if (tab != null) tab.zoomMinus();
    }
    @Action public void zoomReset() {
        DiagramView tab = getCurrentTab();
        if (tab != null) tab.zoomReset();
    }
    @Action public void zoomFit() {
        DiagramView tab = getCurrentTab();
        if (tab != null) tab.zoomFit();
    }
    
    @Action public void helpBug() {
        actions.onHelpBug();
    }
    @Action public void helpAbout() {
        (new DialogAboutBox(properties, locale, this.getFrame())).setVisible(true);
    }
    
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        editToolBar = new javax.swing.JToolBar();
        editToolUndo = new javax.swing.JButton();
        editToolRedo = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        editToolCut = new javax.swing.JButton();
        editToolCopy = new javax.swing.JButton();
        editToolPaste = new javax.swing.JButton();
        editToolRemove = new javax.swing.JButton();
        editToolDelete = new javax.swing.JButton();
        jSeparator6 = new javax.swing.JToolBar.Separator();
        zoomToolMore = new javax.swing.JButton();
        zoomToolLess = new javax.swing.JButton();
        zoomToolReset = new javax.swing.JButton();
        zoomToolFit = new javax.swing.JButton();
        contentPanel = new javax.swing.JPanel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        fileNewProject = new javax.swing.JMenuItem();
        fileNewDiagram = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        fileOpenProject = new javax.swing.JMenuItem();
        fileCloseProject = new javax.swing.JMenuItem();
        jSeparator5 = new javax.swing.JPopupMenu.Separator();
        fileExport = new javax.swing.JMenuItem();
        jSeparator7 = new javax.swing.JPopupMenu.Separator();
        fileSave = new javax.swing.JMenuItem();
        fileSaveAs = new javax.swing.JMenuItem();
        fileSaveAll = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        javax.swing.JMenuItem fileExit = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        editUndo = new javax.swing.JMenuItem();
        editRedo = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JPopupMenu.Separator();
        editCut = new javax.swing.JMenuItem();
        editCopy = new javax.swing.JMenuItem();
        editPaste = new javax.swing.JMenuItem();
        editRemove = new javax.swing.JMenuItem();
        editDelete = new javax.swing.JMenuItem();
        viewMenu = new javax.swing.JMenu();
        viewProjects = new javax.swing.JMenuItem();
        viewToolboxes = new javax.swing.JMenuItem();
        viewOutput = new javax.swing.JMenuItem();
        jSeparator8 = new javax.swing.JPopupMenu.Separator();
        viewZoom = new javax.swing.JMenu();
        zoomPlus = new javax.swing.JMenuItem();
        zoomMinus = new javax.swing.JMenuItem();
        jSeparator9 = new javax.swing.JPopupMenu.Separator();
        zoomReset = new javax.swing.JMenuItem();
        zoomFit = new javax.swing.JMenuItem();
        runMenu = new javax.swing.JMenu();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem bugMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();

        mainPanel.setName("mainPanel");

        editToolBar.setRollover(true);
        editToolBar.setToolTipText(locale.editToolBar_text);
        editToolBar.setName("editToolBar");

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(xowl.gmi.environment.Main.class).getContext().getActionMap(MainView.class, this);
        editToolUndo.setAction(actionMap.get("editUndo"));
        editToolUndo.setIcon(IconProvider.getEmbedded(locale.editToolUndo_icon));
        editToolUndo.setToolTipText(locale.editToolUndo_text);
        editToolUndo.setText(null);
        editToolUndo.setFocusable(false);
        editToolUndo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editToolUndo.setName("editToolUndo");
        editToolUndo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(editToolUndo);

        editToolRedo.setAction(actionMap.get("editRedo"));
        editToolRedo.setIcon(IconProvider.getEmbedded(locale.editToolRedo_icon));
        editToolRedo.setToolTipText(locale.editToolRedo_text);
        editToolRedo.setText(null);
        editToolRedo.setFocusable(false);
        editToolRedo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editToolRedo.setName("editToolRedo");
        editToolRedo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(editToolRedo);

        jSeparator1.setName("jSeparator1");
        editToolBar.add(jSeparator1);

        editToolCut.setAction(actionMap.get("editCut"));
        editToolCut.setIcon(IconProvider.getEmbedded(locale.editToolCut_icon));
        editToolCut.setToolTipText(locale.editToolCut_text);
        editToolCut.setText(null);
        editToolCut.setFocusable(false);
        editToolCut.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editToolCut.setName("editToolCut");
        editToolCut.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(editToolCut);

        editToolCopy.setAction(actionMap.get("editCopy"));
        editToolCopy.setIcon(IconProvider.getEmbedded(locale.editToolCopy_icon));
        editToolCopy.setToolTipText(locale.editToolCopy_text);
        editToolCopy.setText(null);
        editToolCopy.setFocusable(false);
        editToolCopy.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editToolCopy.setName("editToolCopy");
        editToolCopy.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(editToolCopy);

        editToolPaste.setAction(actionMap.get("editPaste"));
        editToolPaste.setIcon(IconProvider.getEmbedded(locale.editToolPaste_icon));
        editToolPaste.setToolTipText(locale.editToolPaste_text);
        editToolPaste.setText(null);
        editToolPaste.setFocusable(false);
        editToolPaste.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editToolPaste.setName("editToolPaste");
        editToolPaste.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(editToolPaste);

        editToolRemove.setAction(actionMap.get("editRemove"));
        editToolRemove.setIcon(IconProvider.getEmbedded(locale.editToolRemove_icon));
        editToolRemove.setToolTipText(locale.editToolRemove_text);
        editToolRemove.setText(null);
        editToolRemove.setFocusable(false);
        editToolRemove.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editToolRemove.setName("editToolRemove");
        editToolRemove.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(editToolRemove);

        editToolDelete.setAction(actionMap.get("editDelete"));
        editToolDelete.setIcon(IconProvider.getEmbedded(locale.editToolDelete_icon));
        editToolDelete.setToolTipText(locale.editToolDelete_text);
        editToolDelete.setText(null);
        editToolDelete.setFocusable(false);
        editToolDelete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editToolDelete.setName("editToolDelete");
        editToolDelete.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(editToolDelete);

        jSeparator6.setName("jSeparator6");
        editToolBar.add(jSeparator6);

        zoomToolMore.setAction(actionMap.get("zoomPlus"));
        zoomToolMore.setIcon(IconProvider.getEmbedded(locale.zoomToolMore_icon));
        zoomToolMore.setToolTipText(locale.zoomToolMore_text);
        zoomToolMore.setText(null);
        zoomToolMore.setFocusable(false);
        zoomToolMore.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        zoomToolMore.setName("zoomToolMore");
        zoomToolMore.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(zoomToolMore);

        zoomToolLess.setAction(actionMap.get("zoomMinus"));
        zoomToolLess.setIcon(IconProvider.getEmbedded(locale.zoomToolLess_icon));
        zoomToolLess.setToolTipText(locale.zoomToolLess_text);
        zoomToolLess.setText(null);
        zoomToolLess.setFocusable(false);
        zoomToolLess.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        zoomToolLess.setName("zoomToolLess");
        zoomToolLess.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(zoomToolLess);

        zoomToolReset.setAction(actionMap.get("zoomReset"));
        zoomToolReset.setIcon(IconProvider.getEmbedded(locale.zoomToolReset_icon));
        zoomToolReset.setToolTipText(locale.zoomToolReset_text);
        zoomToolReset.setText(null);
        zoomToolReset.setFocusable(false);
        zoomToolReset.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        zoomToolReset.setName("zoomToolReset");
        zoomToolReset.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(zoomToolReset);

        zoomToolFit.setAction(actionMap.get("zoomFit"));
        zoomToolFit.setIcon(IconProvider.getEmbedded(locale.zoomToolFit_icon));
        zoomToolFit.setToolTipText(locale.zoomToolFit_text);
        zoomToolFit.setText(null);
        zoomToolFit.setFocusable(false);
        zoomToolFit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        zoomToolFit.setName("zoomToolFit");
        zoomToolFit.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editToolBar.add(zoomToolFit);

        contentPanel.setName("contentPanel");

        javax.swing.GroupLayout contentPanelLayout = new javax.swing.GroupLayout(contentPanel);
        contentPanel.setLayout(contentPanelLayout);
        contentPanelLayout.setHorizontalGroup(
            contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 577, Short.MAX_VALUE)
        );
        contentPanelLayout.setVerticalGroup(
            contentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 273, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(editToolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 577, Short.MAX_VALUE)
            .addComponent(contentPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(editToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(contentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        menuBar.setName("menuBar");

        fileMenu.setText(locale.fileMenu_text);
        fileMenu.setName("fileMenu");

        fileNewProject.setAction(actionMap.get("fileNewProject"));
        fileNewProject.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        fileNewProject.setIcon(IconProvider.getEmbedded(locale.fileNewProject_icon));
        fileNewProject.setText(locale.fileNewProject_text);
        fileNewProject.setName("fileNewProject");
        fileMenu.add(fileNewProject);

        fileNewDiagram.setAction(actionMap.get("fileNewDiagram"));
        fileNewDiagram.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        fileNewDiagram.setIcon(IconProvider.getEmbedded(locale.fileNewDiagram_icon));
        fileNewDiagram.setText(locale.fileNewDiagram_text);
        fileNewDiagram.setName("fileNewDiagram");
        fileMenu.add(fileNewDiagram);

        jSeparator3.setName("jSeparator3");
        fileMenu.add(jSeparator3);

        fileOpenProject.setAction(actionMap.get("fileOpenProject"));
        fileOpenProject.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        fileOpenProject.setIcon(IconProvider.getEmbedded(locale.fileOpenProject_icon));
        fileOpenProject.setText(locale.fileOpenProject_text);
        fileOpenProject.setName("fileOpenProject");
        fileMenu.add(fileOpenProject);

        fileCloseProject.setAction(actionMap.get("fileCloseProject"));
        fileCloseProject.setIcon(IconProvider.getEmbedded(locale.fileCloseProject_icon));
        fileCloseProject.setText(locale.fileCloseProject_text);
        fileCloseProject.setName("fileCloseProject");
        fileMenu.add(fileCloseProject);

        jSeparator5.setName("jSeparator5");
        fileMenu.add(jSeparator5);

        fileExport.setAction(actionMap.get("fileExport"));
        fileExport.setIcon(IconProvider.getEmbedded(locale.fileExport_icon));
        fileExport.setText(locale.fileExport_text);
        fileExport.setName("fileExport");
        fileMenu.add(fileExport);

        jSeparator7.setName("jSeparator7");
        fileMenu.add(jSeparator7);

        fileSave.setAction(actionMap.get("fileSave"));
        fileSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        fileSave.setIcon(IconProvider.getEmbedded(locale.fileSave_icon));
        fileSave.setText(locale.fileSave_text);
        fileSave.setName("fileSave");
        fileMenu.add(fileSave);

        fileSaveAs.setAction(actionMap.get("fileSaveAs"));
        fileSaveAs.setIcon(IconProvider.getEmbedded(locale.fileSaveAs_icon));
        fileSaveAs.setText(locale.fileSaveAs_text);
        fileSaveAs.setName("fileSaveAs");
        fileMenu.add(fileSaveAs);

        fileSaveAll.setAction(actionMap.get("fileSaveAll"));
        fileSaveAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        fileSaveAll.setIcon(IconProvider.getEmbedded(locale.fileSaveAll_icon));
        fileSaveAll.setText(locale.fileSaveAll_text);
        fileSaveAll.setName("fileSaveAll");
        fileMenu.add(fileSaveAll);

        jSeparator2.setName("jSeparator2");
        fileMenu.add(jSeparator2);

        fileExit.setAction(actionMap.get("quit"));
        fileExit.setIcon(IconProvider.getEmbedded(locale.fileExit_icon));
        fileExit.setName("fileExit");
        fileMenu.add(fileExit);

        menuBar.add(fileMenu);

        editMenu.setText(locale.editMenu_text);
        editMenu.setName("editMenu");

        editUndo.setAction(actionMap.get("editUndo"));
        editUndo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK));
        editUndo.setIcon(IconProvider.getEmbedded(locale.editUndo_icon));
        editUndo.setText(locale.editUndo_text);
        editUndo.setName("editUndo");
        editMenu.add(editUndo);

        editRedo.setAction(actionMap.get("editRedo"));
        editRedo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y, java.awt.event.InputEvent.CTRL_MASK));
        editRedo.setIcon(IconProvider.getEmbedded(locale.editRedo_icon));
        editRedo.setText(locale.editRedo_text);
        editRedo.setName("editRedo");
        editMenu.add(editRedo);

        jSeparator4.setName("jSeparator4");
        editMenu.add(jSeparator4);

        editCut.setAction(actionMap.get("editCut"));
        editCut.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
        editCut.setIcon(IconProvider.getEmbedded(locale.editCut_icon));
        editCut.setText(locale.editCut_text);
        editCut.setName("editCut");
        editMenu.add(editCut);

        editCopy.setAction(actionMap.get("editCopy"));
        editCopy.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        editCopy.setIcon(IconProvider.getEmbedded(locale.editCopy_icon));
        editCopy.setText(locale.editCopy_text);
        editCopy.setName("editCopy");
        editMenu.add(editCopy);

        editPaste.setAction(actionMap.get("editPaste"));
        editPaste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK));
        editPaste.setIcon(IconProvider.getEmbedded(locale.editPaste_icon));
        editPaste.setText(locale.editPaste_text);
        editPaste.setName("editPaste");
        editMenu.add(editPaste);

        editRemove.setAction(actionMap.get("editRemove"));
        editRemove.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, 0));
        editRemove.setIcon(IconProvider.getEmbedded(locale.editRemove_icon));
        editRemove.setText(locale.editRemove_text);
        editRemove.setName("editRemove");
        editMenu.add(editRemove);

        editDelete.setAction(actionMap.get("editDelete"));
        editDelete.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, java.awt.event.InputEvent.SHIFT_MASK));
        editDelete.setIcon(IconProvider.getEmbedded(locale.editDelete_icon));
        editDelete.setText(locale.editDelete_text);
        editDelete.setName("editDelete");
        editMenu.add(editDelete);

        menuBar.add(editMenu);

        viewMenu.setText(locale.viewMenu_text);
        viewMenu.setName("View");

        viewProjects.setAction(actionMap.get("viewRequestProjects"));
        viewProjects.setIcon(IconProvider.getEmbedded(locale.viewProjects_icon));
        viewProjects.setText(locale.viewProjects_text);
        viewProjects.setName("viewProjects");
        viewMenu.add(viewProjects);

        viewToolboxes.setAction(actionMap.get("viewRequestToolboxes"));
        viewToolboxes.setIcon(IconProvider.getEmbedded(locale.viewToolboxes_icon));
        viewToolboxes.setText(locale.viewToolboxes_text);
        viewToolboxes.setName("viewToolboxes");
        viewMenu.add(viewToolboxes);

        viewOutput.setAction(actionMap.get("viewRequestOutput"));
        viewOutput.setIcon(IconProvider.getEmbedded(locale.viewOutput_icon));
        viewOutput.setText(locale.viewOutput_text);
        viewOutput.setName("viewOutput");
        viewMenu.add(viewOutput);

        jSeparator8.setName("jSeparator8");
        viewMenu.add(jSeparator8);

        viewZoom.setIcon(IconProvider.getEmbedded(locale.viewZoom_icon));
        viewZoom.setText(locale.viewZoom_text);
        viewZoom.setName("viewZoom");

        zoomPlus.setAction(actionMap.get("zoomPlus"));
        zoomPlus.setIcon(IconProvider.getEmbedded(locale.zoomPlus_icon));
        zoomPlus.setText(locale.zoomPlus_text);
        zoomPlus.setName("zoomPlus");
        viewZoom.add(zoomPlus);

        zoomMinus.setAction(actionMap.get("zoomMinus"));
        zoomMinus.setIcon(IconProvider.getEmbedded(locale.zoomMinus_icon));
        zoomMinus.setText(locale.zoomMinus_text);
        zoomMinus.setName("zoomMinus");
        viewZoom.add(zoomMinus);

        jSeparator9.setName("jSeparator9");
        viewZoom.add(jSeparator9);

        zoomReset.setAction(actionMap.get("zoomReset"));
        zoomReset.setIcon(IconProvider.getEmbedded(locale.zoomReset_icon));
        zoomReset.setText(locale.zoomReset_text);
        zoomReset.setName("zoomReset");
        viewZoom.add(zoomReset);

        zoomFit.setAction(actionMap.get("zoomFit"));
        zoomFit.setIcon(IconProvider.getEmbedded(locale.zoomFit_icon));
        zoomFit.setText(locale.zoomFit_text);
        zoomFit.setName("zoomFit");
        viewZoom.add(zoomFit);

        viewMenu.add(viewZoom);

        menuBar.add(viewMenu);

        runMenu.setText(locale.runMenu_text);
        runMenu.setName("runMenu");
        menuBar.add(runMenu);

        helpMenu.setText(locale.helpMenu_text);
        helpMenu.setName("helpMenu");

        bugMenuItem.setAction(actionMap.get("helpBug"));
        bugMenuItem.setText(locale.bugMenuItem_text);
        bugMenuItem.setIcon(IconProvider.getEmbedded(locale.bugMenuItem_icon));
        helpMenu.add(bugMenuItem);
        
        aboutMenuItem.setAction(actionMap.get("helpAbout"));
        aboutMenuItem.setText(locale.aboutMenuItem_text);
        aboutMenuItem.setIcon(IconProvider.getEmbedded(locale.aboutMenuItem_icon));
        aboutMenuItem.setName("aboutMenuItem");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setComponent(mainPanel);
        setMenuBar(menuBar);
    }

    private javax.swing.JMenu viewMenu;
    private javax.swing.JPanel contentPanel;
    private javax.swing.JMenuItem editCopy;
    private javax.swing.JMenuItem editCut;
    private javax.swing.JMenuItem editDelete;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem editPaste;
    private javax.swing.JMenuItem editRedo;
    private javax.swing.JMenuItem editRemove;
    private javax.swing.JToolBar editToolBar;
    private javax.swing.JButton editToolCopy;
    private javax.swing.JButton editToolCut;
    private javax.swing.JButton editToolDelete;
    private javax.swing.JButton editToolPaste;
    private javax.swing.JButton editToolRedo;
    private javax.swing.JButton editToolRemove;
    private javax.swing.JButton editToolUndo;
    private javax.swing.JMenuItem editUndo;
    private javax.swing.JMenuItem fileCloseProject;
    private javax.swing.JMenuItem fileExport;
    private javax.swing.JMenuItem fileNewDiagram;
    private javax.swing.JMenuItem fileNewProject;
    private javax.swing.JMenuItem fileOpenProject;
    private javax.swing.JMenuItem fileSave;
    private javax.swing.JMenuItem fileSaveAll;
    private javax.swing.JMenuItem fileSaveAs;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JPopupMenu.Separator jSeparator4;
    private javax.swing.JPopupMenu.Separator jSeparator5;
    private javax.swing.JToolBar.Separator jSeparator6;
    private javax.swing.JPopupMenu.Separator jSeparator7;
    private javax.swing.JPopupMenu.Separator jSeparator8;
    private javax.swing.JPopupMenu.Separator jSeparator9;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenu runMenu;
    private javax.swing.JMenuItem viewOutput;
    private javax.swing.JMenuItem viewProjects;
    private javax.swing.JMenuItem viewToolboxes;
    private javax.swing.JMenu viewZoom;
    private javax.swing.JMenuItem zoomFit;
    private javax.swing.JMenuItem zoomMinus;
    private javax.swing.JMenuItem zoomPlus;
    private javax.swing.JMenuItem zoomReset;
    private javax.swing.JButton zoomToolFit;
    private javax.swing.JButton zoomToolLess;
    private javax.swing.JButton zoomToolMore;
    private javax.swing.JButton zoomToolReset;
}
